<template>
  <!-- <router-view></router-view> -->
  {{ info.nickName }}-用户名测试
  <el-button @click="changeUserName">更改用户名</el-button>
  <el-button type="primary" @click="handleReset">重置</el-button>
  <el-config-provider :locale="locale">
    <img src="@/assets/logo.png">
    <div>
      <a href="https://vitejs.dev" target="_blank">
        <img src="/vite.svg" class="logo" alt="Vite logo" />
      </a>
      {{ parent }} ---- 父级
      <a href="https://vuejs.org/" target="_blank">
        <img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
      </a>
    </div>
    <HelloWorld msg="Vite + Vue3" ref="helloWorld" @sendMsg="sendMsg">
      <template #footer="scope">{{ scope.msg }}</template>
    </HelloWorld>
    <Test v-model="test" ref="hello"></Test>
    <el-button @click="handleTest">测试传参</el-button>
    <router-view></router-view>
    <el-button @click="switchLanguage">切换语言</el-button>
    <el-empty></el-empty>
  </el-config-provider>
</template>

<script setup>
import HelloWorld from './components/HelloWorld.vue'
import Test from './components/Test.vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import en from 'element-plus/dist/locale/en.mjs'
import { userInfo } from '@/store/user.js'

const info = userInfo()
const changeUserName = () => {
  info.setName('wang')
}
const handleReset = () => {
  info.$reset()
}
const parent = ref(32)
const test = ref('tes33t')
const hello = ref(null);
const helloWorld = ref()
const language = ref('zh-cn')
const locale = computed(() => (language.value === 'zh-cn' ? zhCn : en))
const sendMsg = (val) => {
  parent.value = val
  hello.value.addCount()
}
const handleTest = () => {
  hello.value.addCount()
}
const switchLanguage = () => {
  language.value = language.value === 'zh-cn' ? 'en' : 'zh-cn'
}
provide('info', 'info33')
</script>

<style scoped>
.logo {
  height: 6em;
  padding: 1.5em;
  will-change: filter;
}
.logo:hover {
  filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
  filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
